package com.xyy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xyy.entity.Doctor;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;

/**
 * 医生Mapper接口
 */
@Mapper
public interface DoctorMapper extends BaseMapper<Doctor> {
    
    /**
     * 查询已删除的医生（只返回必要字段）
     */
    @Select("SELECT id, username, real_name, phone, email, gender, create_time FROM doctor WHERE deleted = 1 ORDER BY create_time DESC")
    List<Doctor> selectDeletedDoctors();
    
    /**
     * 统计已删除医生的总数
     */
    @Select("SELECT COUNT(*) FROM doctor WHERE deleted = 1")
    Long countDeletedDoctors();
    
    /**
     * 根据ID查询已删除的医生（用于恢复操作）
     */
    @Select("SELECT * FROM doctor WHERE id = #{doctorId} AND deleted = 1")
    Doctor selectDeletedDoctorById(Long doctorId);
    
    /**
     * 恢复已删除的医生（设置deleted=0）
     */
    @Update("UPDATE doctor SET deleted = 0 WHERE id = #{doctorId} AND deleted = 1")
    int restoreDoctorById(Long doctorId);
} 
